import {
	query,
	post,
	remove
} from "./request"
//获取我的银行卡账号
export function getMyBank() {
	return query('/account/myBankAccountInfo')
}
//获取银行列表
export function getBankList() {
	return query('/account/bankList')
}
//创建/编辑银行卡账号
export function updateBankAccount(data) {
	return post('/account/updateBankAccountInfo',data)
}
export function getAllLocationTree() {
	return query('/baseData/getAllLocationTree')
}

export function getCityList() {
	return query('/baseData/getCityAllLocations')
}
//获取用户是否有手机号
export function getUserInfo() {
	return query('/user/getUserProfileInfo')
}
//获取用户是否支付
export function getPayStatus(data) {
	return query('/house/reserveOrderPayResult',data)
}
// 优惠券列表
export function myCoupon(data) {
	return query('/user/validCouponList',data)
}
export function register(data) {
	return post('/user/register', data)
}

export function login(data) {
	return post('/user/login', data)
}
export function googleLogin(data) {
	    return post('/user/userLoginByGoogle', data)
}
export function houseList(data) {
	return query('/house/subList', data)
}
export function myHouselnfo() {
	return query('/house/myHouseInfo')
}
export function houseSearch(data) {
	return query('/house/search', data)
}
export function savedList(data) {
	return query('/userLike/subList', data)
}
export function getArea(data) {
	return query('/house/areaList', data)
}
export function getAllArea(data) {
	return query('/house/allAreaList', data)
}
// 获取房源评价列表
export function getReviewList(data) {
	return query('/house/reviewList', data)
}
//评价房源
export function getReview(data) {
	return post('/house/review', data)
}

export function reserveDateInfo(data) {
	return query('/house/reserveDateInfo', data)
}
//房价估算
export function estimateRentPrice(data) {
	return post('/house/estimateRentPrice', data)
}

// 长租房价估算
export function estimateLongRentPrice(data) {
	return post('/house/estimateLongRentPrice', data)
}

//预定创建订单

export function createReserveOrder(data) {
	return post('/house/createReserveOrder', data)
}

//房东回复
export function getReplyReview(data) {
	return post('/house/replyReview', data)
}


//获取房源图片列表
export function picsFromUrl(data) {
	return query('/house/picsFromUrl', data)
}
export function submitHouse(data) {
	return post('/house/save', data)
}
// 预定房源
export function submitReserve(data) {
	return post('/house/reserve', data)
}
//我的行程
export function getMyReserve(data) {
	return query('/house/myReserve', data)
}
//中介订单
export function agencyOrderList(data) {
	return query('/house/agencyOrderList', data)
}
//邀请奖励分佣订单列表
export function traderOrderList(data) {
	return query('/house/traderOrderList', data)
}

//取消房源预定
export function cancelReserve(data) {
	return post('/house/cancelReserve', data)
}

export function updateHouse(data) {
	return post('/house/edit', data)
}
export function removeHouse(id) {
	return remove('/house/delete?ids=' + id)
}

export function updateUser(id, data) {
	return post('/user/edit', {
		id: id,
		...data
	})
}



export function emailCode(email) {
	return post('/user/getCaptchaByEmail', {
		email
	})
}

export function updateSaved(houseId, flag, likeId) {
	if (!flag) {
		return post('/userLike/save', {
			houseId: houseId
		})
	} else {
		return remove('/userLike/delete?ids=' + likeId)
	}
}

export function dict(data) {
	return query('/baseData/getAllDicts',data)
}

export function getHouseDetail(id) {
	return query('/house/get', {
		id: id
	})
}

export function policy(fileType, fileName) {
	return query('/file/policy', {
		fileType,
		fileName
	})
}

export function check(data) {
	return post('/order/save', data)
}
export function removeOrder(id) {
	return remove('/order/delete?ids=' + id)
}
export function orderList(houseId, params) {
	return query('/order/subList', {
		houseId,
		...params
	})
}
export function orderDetail(id) {
	return query('/order/get', {
		id
	})
}
export function updateOrder(id, data) {
	return post('/order/edit', {
		id,
		...data
	})
}
//绑定邀请关系
export function bindInviteCode(data) {
	return post('/user/bindShareRelation', data)
}
//获取绑定的邀请码
export function getInviteCode() {
	return query('/user/myBindShareRelation')
}
//注销账户
export function logOff() {
	return post('/user/logOff')
}
//获取当天打卡情况
export function getSignInfo() {
	return query('/user/todaySignInfo')
}
//打卡
export function todaySign(data) {
	return post('/user/sign',data)
}
//获取打卡清单

export function getSignList(data) {
	return query('/user/signList',data)
}
//获取自己的商家状态
export function myShopStatus() {
	return query('/shop/myShopStatus')
}
//获取商家类别
export function shopCategories() {
	return query('/shop/shopCategories')
}
//商家提交申请
export function applyShop(data) {
	return post('/shop/request', data)
}
//获取商家后台数据
export function myShopData() {
	return query('/shop/myShopData')
}
//商家查看商品列表
export function itemListForShoper(data) {
	return query('/item/itemListForShoper', data)
}
//商家查看商品详情
export function itemDetailForShoper(data) {
	return query('/item/itemDetailForShoper', data)
}
//新建商品
export function addGoods(data) {
	return post('/item/addItem', data)
}
//编辑商品
export function editItem(data) {
	return post('/item/editItem', data)
}
//上架商品
export function upItem(data) {
	return post('/item/upItem', data)
}
//下架商品
export function downItem(data) {
	return post('/item/downItem', data)
}
//删除商品
export function deleteItem(data) {
	return post('/item/deleteItem', data)
}
//获取折扣价
export function getDiscountPrice(data) {
	return query('/item/getDiscountPrice', data)
}
export function makeCall(number) {
	if (plus.os.name == "Android") {
		var Intent = plus.android.importClass("android.content.Intent");
		var Uri = plus.android.importClass("android.net.Uri");
		var main = plus.android.runtimeMainActivity();
		var uri = Uri.parse("tel:" + number);
		var call = new Intent("android.intent.action.CALL", uri);
		main.startActivity(call);
	} else {
		//plus.device.dial(number, false);  
		var UIAPP = plus.ios.importClass("UIApplication");
		var NSURL = plus.ios.importClass("NSURL");

		var app = UIAPP.sharedApplication();

		app.openURL(NSURL.URLWithString("tel://" + number));
	}
};

export function makeSMS(number, text) {
	if (plus.os.name == "Android") {

		var Intent = plus.android.importClass("android.content.Intent");
		var Uri = plus.android.importClass("android.net.Uri");

		var uri = Uri.parse("smsto:" + number);

		var intent = new Intent(Intent.ACTION_SENDTO, uri);
		intent.putExtra("sms_body", "");

		plus.android.runtimeMainActivity().startActivity(intent);
	} else {
		var UIAPP = plus.ios.importClass("UIApplication");
		var NSURL = plus.ios.importClass("NSURL");
		var app = UIAPP.sharedApplication();
		app.openURL(NSURL.URLWithString("sms://" + number));
	}
};


export function makeEmail(number, text) {
	if (plus.os.name == "Android") {

		var Intent = plus.android.importClass("android.content.Intent");
		var Uri = plus.android.importClass("android.net.Uri");

		var uri = Uri.parse("mailto:" + number);

		var intent = new Intent(Intent.ACTION_SENDTO, uri);

		plus.android.runtimeMainActivity().startActivity(intent);
	} else {
		var UIAPP = plus.ios.importClass("UIApplication");
		var NSURL = plus.ios.importClass("NSURL");
		var app = UIAPP.sharedApplication();
		app.openURL(NSURL.URLWithString("mailto://" + number));
	}
};